// app/api/branches/[branch]/[year]/[month]/days/route.js import { NextResponse } from "next/server"; import { listDays } from "@/lib/storage"; /** * GET /api/branches/[branch]/[year]/[month]/days * * Returns the list of day folders for a given branch, year, and month. * Example: /api/branches/NL01/2024/10/days → { days: ["01", "02", ...] } */ export async function GET(request, ctx) { const { branch, year, month } = await ctx.params; console.log("[/api/branches/[branch]/[year]/[month]/days] params:", { branch, year, month, }); if (!branch || !year || !month) { return NextResponse.json( { error: "branch, year oder month fehlt" }, { status: 400 } ); } try { const days = await listDays(branch, year, month); return NextResponse.json({ branch, year, month, days }); } catch (error) { console.error("[/api/branches/[branch]/[year]/[month]/days] Error:", error); return NextResponse.json( { error: "Fehler beim Lesen der Tage: " + error.message }, { status: 500 } ); } }